package Eyjafjalla.relic;

import Eyjafjalla.helper.StringHelper;
import Eyjafjalla.power.ResplendentTearPower;
import basemod.abstracts.CustomRelic;
import com.megacrit.cardcrawl.actions.common.ApplyPowerAction;
import com.megacrit.cardcrawl.actions.common.GainEnergyAction;
import com.megacrit.cardcrawl.actions.common.RelicAboveCreatureAction;
import com.megacrit.cardcrawl.actions.utility.UseCardAction;
import com.megacrit.cardcrawl.cards.AbstractCard;
import com.megacrit.cardcrawl.dungeons.AbstractDungeon;
import com.megacrit.cardcrawl.helpers.ImageMaster;
import com.megacrit.cardcrawl.relics.AbstractRelic;

public class ResplendentTear extends CustomRelic {

    public static final String ID = "eyjafjalla:ResplendentTear";

    private boolean gainAttackNext = false;
    private boolean firstTurn = false;

    public ResplendentTear(){
        super(ID, ImageMaster.loadImage(StringHelper.getRelicIMGPATH(ID,false)),ImageMaster.loadImage(StringHelper.getRelicIMGPATH(ID,true)),RelicTier.UNCOMMON,LandingSound.MAGICAL);
    }

    public void atPreBattle() {
        this.flash();
        this.firstTurn = true;
        this.gainAttackNext = true;
        if (!this.pulse) {
            this.beginPulse();
            this.pulse = true;
        }

    }

    public void atTurnStart() {
        this.beginPulse();
        this.pulse = true;
        if (this.gainAttackNext && !this.firstTurn) {
            this.flash();
            this.addToBot(new RelicAboveCreatureAction(AbstractDungeon.player, this));
            this.addToBot(new ApplyPowerAction(AbstractDungeon.player,AbstractDungeon.player,new ResplendentTearPower(AbstractDungeon.player,1),1));
        }

        this.firstTurn = false;
        this.gainAttackNext = true;
    }

    public void onUseCard(AbstractCard card, UseCardAction action) {
        if (card.type == AbstractCard.CardType.ATTACK) {
            this.gainAttackNext = false;
            this.pulse = false;
        }

    }

    public void onVictory() {
        this.pulse = false;
    }


    @Override
    public String getUpdatedDescription() {
        return DESCRIPTIONS[0];
    }

    @Override
    public AbstractRelic makeCopy() {
        return new ResplendentTear();
    }
}



